package com.gw.smscheck.controller.business.statistic;

import com.alibaba.fastjson.JSON;
import com.gw.smscheck.entity.business.statistic.JzfdStreamPeopleStatistics;
import com.gw.smscheck.service.business.statistic.JzfdStreamPeopleStatisticsService;
import com.gw.smscheck.util.DateUtil;
import com.gw.smscheck.util.ResultObj;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Api(description="【统计接口】")
@Controller
@RequestMapping("/statisticsController")
public class JzfdStreamPeopleStatisticsController {

    @Autowired
    private JzfdStreamPeopleStatisticsService statisticsService;

    /**
     * 查询所有
     *
     * @return
     */
    @RequestMapping(value = "/findAll", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="查询所有", notes="查询所有")
    public String findAll() {
        List<JzfdStreamPeopleStatistics> list = statisticsService.findAll();
        return JSON.toJSONString(list);
    }

    @RequestMapping(value = "/findCurrent", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="通过条件获取带展示数据", notes="通过条件获取带展示数据")
    public String findCurrent(JzfdStreamPeopleStatistics dto) {
        JzfdStreamPeopleStatistics res = statisticsService.findCurrent(dto);
        //res.setCalledDate(DateUtil.dateToString(DateUtil.stringToDate(res.getCalledDate(), "yyyy-MM-dd"),"yyyy 年 MM 月 dd 日"));
        return ResultObj.successResultObj(res);
    }

    @RequestMapping(value = "/findByModal", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="通过条件获取带展示数据", notes="通过条件获取带展示数据")
    public String findByModal(JzfdStreamPeopleStatistics dto) {
        JzfdStreamPeopleStatistics res = statisticsService.findByModal(dto);
        //res.setCalledDate(DateUtil.dateToString(DateUtil.stringToDate(res.getCalledDate(), "yyyy-MM-dd"),"yyyy 年 MM 月 dd 日"));
        return ResultObj.successResultObj(res);
    }
}
